<?php
include("config.php");
session_start();

//login
if($_SERVER["REQUEST_METHOD"] == "POST")
{
	// username and password sent from Form 
	$myusername=addslashes($_POST['username']); 
	$mypassword=addslashes($_POST['password']); 

	//$sql="SELECT id,role FROM admin WHERE username='$myusername' and passcode='$mypassword'";
	$sql="SELECT id,role,passcode FROM admin WHERE username='$myusername'";
	
	$result=mysql_query($sql);
	$row=mysql_fetch_array($result);
	//echo $row[0];
	$active=$row['active'];
	$passwordDb = $row['passcode'];
	$count=mysql_num_rows($result);


	// If result matched $myusername and $mypassword, table row must be 1 row
	if($count==1)
	{
		if($passwordDb == $mypassword)
		{
			echo "True";
		}else
		{
			echo "Wrong password"
		}
	}
	else 
	{
		echo "Your Login Name or Password is invalid";
	}
}
?>

